package cn.com.aiouyi.controller.admin;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import cn.com.aiouyi.common.Message;
import cn.com.aiouyi.common.Setting;
import cn.com.aiouyi.plugin.StoragePlugin.FileType;
import cn.com.aiouyi.util.SystemUtils;

/**
 * Controller - 系统设置
 * 
 * @author hanson
 */
@Controller("adminSettingController")
@RequestMapping("/admin/setting")
public class SettingController extends BaseController {

	/**
	 * 编辑
	 */
	@GetMapping("/edit")
	public String edit(ModelMap model) {
		
		model.put("setting", SystemUtils.getSetting());
		return "/admin/setting/edit";
	}

	/**
	 * 更新
	 */
	@PostMapping("/update")
	public String update(Setting setting, RedirectAttributes redirectAttributes) {
		//Setting srcSetting = SystemUtils.getSetting();
		
		SystemUtils.setSetting(setting);

		addFlashMessage(redirectAttributes, Message.SUCCESS);
		return "redirect:edit";
	}

}